<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'dome4.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	一、JSON格式的user对象:
	<div id="objectDiv"></div>
	<br /> 二、JSON格式的字符串数组:&nbsp;&nasp;
	<select id="arraySel"></select>
	<ul id="arrayUl"></ul>
	三、JSON格式的user对象数组:
	<div id="objectArrayDiv"></div>
	<script type="text/javascript ">
			$(document).ready(function(){
				//定义JSON格式的user对象、并在div中输出
				var user={
					"id":1,
					"name":"张三",
					"pwd":"000"
				};
				$("#objectDiv").append("ID:s"+user.id+"<br/>").append("用户名:"+user.name+"<br/>").append("密码:"+user.pwd+"<br/>");
				//定义JSON格式的字符串数组、并在ul和select中输出
				var ary=["美","中","俄"];
				var $ary=$(ary);
				var $ul=$("#arrayUl");
				var $sel=$("#arraySel");
				$ary.each(function(){$ul.append("<li>"+this+"</li>");});
				$ary.each(function(i){
					$sel.append("<option value='"+(i+1)+"'>"+this+"</option>");
				});
				//定义JSON格式的user对象数组、并使用<table>输出
				var userArray=[{
					"id":2,
					"name":"admin",
					"pwd":"123"
				},{
					"id":3,
					"name":"admin",
					"pwd":"123"
					
				},{
					"id":4,
					"name":"admin",
					"pwd":"123"
					
				}];
				var $table=$("<table border='1'></table>").append("<tr><td>ID</td><td>用户名</td><td>删除</td><tr/>").appenTo($("#objectArrayDiv"));
				$(userArray).each(function(){
					$table.append("<tr><td>"+this.id+"</td><td>"+this.name+"</td><td>"+this.pwd+"</td><tr/>");
				});	
			});
		</script>
</body>
</html>
